package com.qf.agro.exception;

import com.qf.agro.common.CustomException;
import com.qf.agro.common.ResultInfo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author 10202
 * @version V1.0
 * @Project smart-agriculture-parent
 * @Package com.qf.agro.exception
 * @Date 2023/5/24 11:25
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(CustomException.class)
    private ResultInfo cusExceptionHandler(CustomException customException){
        return ResultInfo.error(customException.getMessage());
    }

    @ExceptionHandler(Exception.class)
    private ResultInfo cusExceptionHandler(Exception e){
        return ResultInfo.error(e.getMessage());
    }

}
